package com.zdy.im.user.controller;



import com.sixeco.framework.common.api.ApiDoc;
import com.sixeco.framework.common.enums.SysResultCodeEnum;
import com.sixeco.framework.http.data.vo.HttpRequestByIdVo;
import com.sixeco.framework.http.data.vo.ResponseResultList;
import com.sixeco.framework.http.handler.OutputResponse;
import com.zdy.im.user.UrlCommand;
import com.zdy.im.user.dto.response.ImRoomUserShipResponseDto;
import com.zdy.im.user.facade.ImRoomUserShipFacade;
import com.zdy.im.user.service.ImRoomUserShipService;
import com.zdy.im.user.vo.request.*;
import com.zdy.im.user.vo.response.ImRoomUserShipShowResponseVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * @Title: ImRoomUserShipController.java
 * @Author 作者 : zdy
 * @CreateDate 创建时间: 2021-02-30
 * @version V1.0
 *  <pre>
 * 修改记录
 *    修改后版本:     修改人：  修改日期:     修改内容:
 * </pre>
 * @Description: TODO(说明) 对象缓存统一模板实现类;
 */
@ApiDoc(
        module = "群与用户关系模块", isApp = true
)
@Controller
public class ImRoomUserShipController {

    @Autowired
    private ImRoomUserShipFacade imRoomUserShipFacade;

    @Autowired
    private ImRoomUserShipService imRoomUserShipService;


    /**
    * @Title: test测试生成类分页信息
    * @Description:testRequestVo @{Link TestRequestVo}
    * @param
    * @return
    * @throw
    * @author suven
    * @date 2019-07-19 13:16:48
    *  --------------------------------------------------------
    *  modifyer    modifyTime                 comment
    *
    *  --------------------------------------------------------
    */
    @ApiDoc(
            value = "分页获取群与用户关系信息",
            request = RoomUserQueryRequestVo.class,
            response = ImRoomUserShipShowResponseVo.class
    )
    @RequestMapping(value = UrlCommand.user_imRoomUserShip_pageList, method = RequestMethod.GET)
    public void list(OutputResponse out, RoomUserQueryRequestVo roomUserQueryRequestVo){
        if (roomUserQueryRequestVo.getRoomId() == 0 ) {
            out.write(SysResultCodeEnum.SYS_WEB_ID_INFO_NO_EXIST);
            return ;
        }
        ResponseResultList list = imRoomUserShipFacade.list(roomUserQueryRequestVo);
        out.write(list);
    }





    /**
    * @Title: 查看test测试生成类信息
    * @Description:testRequestVo @{Link TestRequestVo}
    * @param
    * @return
    * @throw
    * @author suven
    * @date 2019-07-19 13:16:48
    *  --------------------------------------------------------
    *  modifyer    modifyTime                 comment
    *
    *  --------------------------------------------------------
    */
    @ApiDoc(
            value = "查看群与用户关系信息",
            request = HttpRequestByIdVo.class,
            response = ImRoomUserShipShowResponseVo.class
    )
    @RequestMapping(value = UrlCommand.user_imRoomUserShip_info ,method = RequestMethod.GET)
    public void detail(OutputResponse out, HttpRequestByIdVo idRequestVo){

            ImRoomUserShipResponseDto imRoomUserShipResponseDto = imRoomUserShipService.getImRoomUserShipById(idRequestVo.getId());
            ImRoomUserShipShowResponseVo vo =  ImRoomUserShipShowResponseVo.build().clone(imRoomUserShipResponseDto);
        out.write(vo);
    }

    @ApiDoc(
            value = "移除群的好友",
            request = RoomUserRequestVo.class,
            response = boolean.class
    )
    @RequestMapping(value = UrlCommand.user_imroomusership_delRoomFriend,method = RequestMethod.POST)
    public  void  del(OutputResponse out, RoomUserRequestVo roomUserRequestVo){
        if (roomUserRequestVo.getRoomId() == 0 || roomUserRequestVo.getUserId() == 0) {
            out.write(SysResultCodeEnum.SYS_WEB_ID_INFO_NO_EXIST);
            return ;
        }
        boolean result = imRoomUserShipFacade.delRoomFriend(roomUserRequestVo);
        out.write(result);
    }

    @ApiDoc(
            value = "修改群好友昵称、设置管理员",
            request = RoomUserNameRequestVo.class,
            response = boolean.class
    )
    @RequestMapping(value = UrlCommand.user_imroomusership_upnickNameRole,method = RequestMethod.POST)
    public  void  upnickName(OutputResponse out, RoomUserNameRequestVo roomUserRequestVo){
        if (roomUserRequestVo.getRoomId() == 0 || roomUserRequestVo.getUserId() == 0) {
            out.write(SysResultCodeEnum.SYS_WEB_ID_INFO_NO_EXIST);
            return ;
        }
        boolean result = imRoomUserShipFacade.upnickName(roomUserRequestVo);
        out.write(result);
    }

    @ApiDoc(
            value = "修改群好友消息设置/群员禁言",
            request = RoomUserNameRequestVo.class,
            response = boolean.class
    )
    @RequestMapping(value = UrlCommand.user_imroomusership_upnickSet,method = RequestMethod.POST)
    public  void  upnickSet(OutputResponse out, RoomUserNameRequestVo roomUserRequestVo){
        if (roomUserRequestVo.getRoomId() == 0 || roomUserRequestVo.getUserId() == 0) {
            out.write(SysResultCodeEnum.SYS_WEB_ID_INFO_NO_EXIST);
            return ;
        }
        boolean result = imRoomUserShipFacade.upnickSet(roomUserRequestVo);
        out.write(result);
    }

    @ApiDoc(
            value = "群加好友",
            request = RoomAddFirendRequestVo.class,
            response = boolean.class
    )
    @RequestMapping(value = UrlCommand.user_imroomusership_add ,method = RequestMethod.POST)
    public void save(OutputResponse out, RoomAddFirendRequestVo roomInfoAddRequestVo){
        if (roomInfoAddRequestVo.getRoomId() == 0) {
            out.write(SysResultCodeEnum.SYS_WEB_ID_INFO_NO_EXIST);
            return ;
        }
        boolean res = imRoomUserShipFacade.add(roomInfoAddRequestVo);
        out.write(res);
    }


    @ApiDoc(
            value = "禁言名单列表信息",
            request = ForbidSpeechRequestVo.class,
            response = ImRoomUserShipShowResponseVo.class
    )
    @RequestMapping(value = UrlCommand.user_imroomusership_forbidSpeechList, method = RequestMethod.GET)
    public void forbidSpeechList(OutputResponse out, ForbidSpeechRequestVo forbidSpeechRequestVo){
        if (forbidSpeechRequestVo.getRoomId() == 0) {
            out.write(SysResultCodeEnum.SYS_WEB_ID_INFO_NO_EXIST);
            return ;
        }
        ResponseResultList<ImRoomUserShipShowResponseVo> resultList = imRoomUserShipFacade.selectForbidSpeechList(forbidSpeechRequestVo);
        out.write(resultList);
    }

    @ApiDoc(
            value = "批量删除群的用户",
            request = RoomUserBatchRequestVo.class,
            response = boolean.class
    )
    @RequestMapping(value = UrlCommand.user_imroomusership_batchDelRoomFriend,method = RequestMethod.POST)
    public  void  batchDelRoomFriend(OutputResponse out, RoomUserBatchRequestVo roomUserRequestVo){
        if (roomUserRequestVo.getRoomId() == 0 ) {
            out.write(SysResultCodeEnum.SYS_WEB_ID_INFO_NO_EXIST);
            return ;
        }
        boolean result = imRoomUserShipFacade.batchDelRoomFriend(roomUserRequestVo);
        out.write(result);
    }
}
